﻿
#ifndef FLOWINGRAYBUTTON_H
#define FLOWINGRAYBUTTON_H

#include <QFrame>
#include <QPushButton>
#include <QWidget>
#include <QLineEdit>
#include <QGraphicsBlurEffect>
#include <QRect>
#include <QSize>
#include <Qt>
#include <QTimer>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QEasingCurve>
#include <QPoint>
#include <QSequentialAnimationGroup>
#include <QAbstractAnimation>
#include <QRegularExpression>
#include <QBrush>
#include <QColor>
#include <QCursor>
#include <QFont>
#include <QPainter>
#include <QPainterPath>
#include <QLinearGradient>
#include <QDebug>
// 流动光线按钮
class FlowingRayButton : public QFrame
{
    Q_OBJECT
public:
    FlowingRayButton(QWidget *parent = nullptr);
    ~FlowingRayButton();
    void setBorder(int border = 5); // 设置按钮在QFrame中的大小
    void setStyleSheetConfig();     // 根据样式重新配置(解析样式设置)
    QPushButton *getFlowingRayButton();
private:
    QPushButton *m_pPushButton;
    int border_radius;              // 边框圆角
    int border;                     // 边界
    QTimer *m_pTimer;
    int rect_1_offset;              //
    int rect_2_offset;
    int rect_1_start;
    int rect_2_start;
    int init_x;
    int flag;
    void initUI();
    void initAnimationConfig();     // 初始化动画配置
    void enterEvent(QEvent *event) override;//重写处理鼠标光标进入部件的事件
    void leaveEvent(QEvent *event) override;//重写处理鼠标光标离开部件的事件
    void paintEvent(QPaintEvent *event) override;//重写绘制事件

private slots:
    void offsetUpdate();            // 偏移更新
};


#endif // FLOWINGRAYBUTTON_H
